package com.tbit.main.controller;


import com.tbit.common.constant.RpcConstants;
import com.tbit.main.common.JsonResult;
import com.tbit.main.pojo.VO.MachineUnOccupyReqVO;
import com.tbit.main.service.MachineOccupyService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 运维占用 Controller
 *
 * @author <a href="mailto:li.yao@tbit.com.cn">yao</a>
 * @version 4.2.1
 * @since 2024/10/21 9:11
 */
@RestController
public class MachineOccupyController {

    @Resource
    private MachineOccupyService machineOccupyService;

    /**
     * 解除占用
     *
     * @param reqVO 请求参数
     */
    @PostMapping("/machineOccupy/unOccupy")
    public JsonResult<String> unOccupy(@Valid MachineUnOccupyReqVO reqVO) {
        machineOccupyService.unOccupy(reqVO);
        return JsonResult.succ();
    }

    /**
     * 批量解除占用
     */
    @PostMapping(RpcConstants.RPC_API_PREFIX + "/machineOccupy/batchUnOccupy")
    public JsonResult<String> batchUnOccupy(@RequestBody List<Integer> machineIds) {
        machineOccupyService.batchUnOccupy(machineIds);
        return JsonResult.succ();
    }


}
